package org.web2024.service.serviceimp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.web2024.dao.Course;
import org.web2024.dao.Teachar;
import org.web2024.dao.UserdetailsImp;
import org.web2024.mapper.TeacherMapper;
import org.web2024.service.TeacherService;

import java.util.List;

@Service
public class TeacherServiceImp implements TeacherService {
    @Autowired
    private TeacherMapper teacherMapper;
    @Override
    public List<Course> selectTeacherCourse(String tno, String selCyear) {
        return teacherMapper.selectTeacherCourse(tno, selCyear);
    }
    @Override
    public Teachar showTeacherInfo() {
        String tno=((UserdetailsImp) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUser().getUser_no();
        return teacherMapper.showTeacherInfo(tno);
    }
    @Override
    public boolean modifyTeacherInfo(Teachar teacher) {
        String t_no=((UserdetailsImp) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUser().getUser_no();
        teacher.setT_no(t_no);
        return teacherMapper.modifyTeacherInfo(teacher);
    }
}
